import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Controls 1.4 as Ctrl1
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtQml.Models 2.2
import ClockController 1.0
import '../../widget'
import '../../labels'

StackPage {
    id:window
    tabIndex: 1

    ClockController{
        id:clockController
    }

    ColumnLayout{
        anchors.fill: parent
        spacing:0
        Rectangle {
            Layout.fillWidth: true
            Layout.preferredHeight: 40
            ReturnImg{
                onClicked: {
                    window.pop();
                }
            }
            TitleLabel {
                text: qsTr("考勤足迹")
                anchors.fill: parent
            }
        }
        Rectangle{
            Layout.fillWidth: true
            Layout.preferredHeight: 40
            ContentLabel{
                text:settings.value("user/department","")+" "+settings.value("user/name","")
                anchors{
                    verticalCenter: parent.verticalCenter
                    left:parent.left
                    leftMargin: 15
                }
            }
            TitleLabel{
                text:"2018.03"
                anchors{
                    verticalCenter: parent.verticalCenter
                    right:listDownImg.left
                    rightMargin: 10
                }
            }
            Image{
                id:listDownImg
                source:"qrc:/img/list_down.png"
                sourceSize:Qt.size(20,20)
                anchors{
                    verticalCenter: parent.verticalCenter
                    right:parent.right
                    rightMargin: 15
                }
            }
        }

        ScrollView{
            id:scrollView
            Layout.fillWidth:true
            Layout.fillHeight: true
            ScrollBar.vertical: ScrollBar {
                parent: scrollView
                x: scrollView.mirrored ? 0 : scrollView.width - width
                y: scrollView.topPadding
                height: scrollView.availableHeight
                active: scrollView.ScrollBar.horizontal.active
            }

            ScrollBar.horizontal: ScrollBar {
                parent: scrollView
                x: scrollView.leftPadding
                y: scrollView.height - height
                width: scrollView.availableWidth
                active: scrollView.ScrollBar.vertical.active
            }
            background: Rectangle {
                border.color: "#FFFFFF"
                color:"#F8F8F8"
            }
            ListView{
                id:listView
                model:clockController.clockStatSlotModel
                section.property: "date"
                section.criteria: ViewSection.FullString
                section.delegate: Rectangle{
                    id:groupRect
                    color:"#FFFFFF"
                    width:scrollView.width
                    height:45
                    function getDate(){
                        return new Date(section)
                    }
                    RowLayout{
                        anchors{
                            left:parent.left
                            leftMargin:15
                        }
                        Label{
                            text:groupRect.getDate().getDate()
                            color:"#5F6873"
                            font{
                                pixelSize: 20
                            }
                        }
                        ContentLabel{
                            text:(groupRect.getDate().getMonth() + 1)+'月'
                        }
                    }
                }
                delegate: Rectangle {
                    width:scrollView.width
                    height:100
                    RowLayout{
                        Rectangle{
                            Layout.preferredWidth: 70
                            Layout.fillHeight: true
                            Label{
                                text:time
                                color:"#5F6873"
                                font{
                                    pixelSize: 17
                                }
                                anchors{
                                    left:parent.left
                                    leftMargin:15
                                }
                            }
                        }
                        ColumnLayout{
                            Layout.fillWidth: true
                            Rectangle{
                                Layout.fillWidth: true
                                Layout.preferredHeight: 15
                                ContentLabel{
                                    text:place
                                    anchors{
                                        left:parent.left
                                        leftMargin:15
                                        verticalCenter: parent.verticalCenter
                                    }
                                }
                            }
                            Rectangle{
                                Layout.fillWidth: true
                                Layout.preferredHeight: 15
                                ContentLabel{
                                    text:place
                                    color:"#B7B7B7"
                                    anchors{
                                        left:parent.left
                                        leftMargin:15
                                        verticalCenter: parent.verticalCenter
                                    }
                                }
                            }
                            Rectangle{
                                Layout.fillWidth: true
                                Layout.preferredHeight: 15
                                ContentLabel{
                                    text:"出差南京"
                                    anchors{
                                        left:parent.left
                                        leftMargin:15
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    Component.onCompleted: {
        var user_id = settings.value("user/pid","0")
        clockController.slot_statslot_req(user_id)
    }
}
